package com.chenexample.myshop16173;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.chenexample.myshop16173.adapter.MyRVAdapter2;
import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration;

import java.util.ArrayList;
import java.util.List;

public class VolunteerActivity extends Fragment {
    RecyclerView recyclerView;
    MyRVAdapter2 adapter;
    List<shuju> list = new ArrayList<>();
    TextView tv_1,tv_2,tv_3;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.activity_volunteer, container, false);
        initdata();
        recyclerView = (RecyclerView) v.findViewById(R.id.recyclerView);
        tv_1 =  v.findViewById(R.id.tv_1);
        tv_2 =  v.findViewById(R.id.tv_2);
        tv_3 =  v.findViewById(R.id.tv_3);
        return v;
    }

    @Override
    public void onStart() {
        adapter = new MyRVAdapter2(getActivity(), list);
        recyclerView.setItemAnimator(new DefaultItemAnimator());
        recyclerView.addItemDecoration(new HorizontalDividerItemDecoration.Builder(getActivity()).build());
        recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
        recyclerView.setAdapter(adapter);
        super.onStart();
    }

    private void initdata() {
        for (int i = 0; i < 2; i++) {
            if (i == 0) {
                shuju s = new shuju();
                s.setCanyurenshu("20");
                s.setZuji("200");
                s.setCyrenshu("25");
                s.setHdmz("《关爱老人，从今天开始》志愿者活动");
                list.add(s);
            } else if (i == 1) {
                shuju s = new shuju();
                s.setCanyurenshu("80");
                s.setZuji("1000");
                s.setCyrenshu("100");
                s.setHdmz("《保护海洋环境，没有买卖就没有杀害》志愿者活动");
                list.add(s);
            }
        }
    }


}
